raise error(filename, lineno, 'identifier found outside of s-expression')
endpos = pos
while endpos < len(line) and line[endpos] not in nonsymbol:
endpos += 1
symbol = line[pos:endpos]
pos = max(pos, endpos - 1)
try:
symbol = int(symbol)
except ValueError:
try:
symbol = float(symbol)
except ValueError:
pass
except:
None<EXCEPTION MATCH>ValueError
None<EXCEPTION MATCH>ValueError
stack[-1] += (symbol,)
pos += 1
if len(stack) != 0:
msg = '%d unclosed parentheses found at end of file (opened on line(s) %s)' % (len(stack), ', '.join(map(str, openlines)))
raise error(filename, lineno, msg)
class Parser:
def __init__(self, filename):
'''Argument is either a string, a parse tree, or file object'''
self.filename = filename
def startParsing(self, filename = None):
if not filename:
pass
statements = parse(self.filename)
for statement in statements:
self.handle(statement)
def handle(self, tup):
cmd = string.translate(tup[0], trans)
if hasattr(self, cmd):
getattr(self, cmd)(*tup[1:])
else:
self.unknown(tup)
def unknown(self, tup):
pass
_testString = '; a scheme file\n(define-func gdk_font_load ; a comment at end of line\n GdkFont\n ((string name)))\n\n(define-boxed GdkEvent\n gdk_event_copy\n gdk_event_free\n "sizeof(GdkEvent)")\n'